package com.example.lenovo.appstore.activity;

import androidx.appcompat.app.AppCompatActivity;
import butterknife.Bind;
import butterknife.ButterKnife;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.lenovo.appstore.R;
import com.example.lenovo.appstore.base.BaseActivity;
import com.example.lenovo.appstore.utils.AppContext;
import com.example.lenovo.appstore.utils.StatusBarUtil;
import com.example.lenovo.appstore.view.TitleBarView;

public class RechargeTypeActivity extends BaseActivity implements View.OnClickListener {
    @Bind(R.id.recharge_type_title)
    TitleBarView recharge_type_title;
    @Bind(R.id.img_alipay)
    ImageView img_alipay;//支付宝
    @Bind(R.id.img_wxpay)
    ImageView wxpay;//微信
    @Bind(R.id.img_cardpay)
    ImageView img_cardpay;//银行卡
    @Bind(R.id.commit_pay)
    TextView commit_pay;//确认支付

    @Bind(R.id.layout_ali)
    RelativeLayout layout_ali;//阿里
    @Bind(R.id.layout_wx)
    RelativeLayout layout_wx;//微信
    @Bind(R.id.layout_card)
    RelativeLayout layout_card;//银行卡

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recharge_type);
        ButterKnife.bind(this);
        initView();

    }

    @Override
    protected void initView() {
        recharge_type_title.setTitle(AppContext.getInstance().getResources().getString(R.string.pay_type));
        recharge_type_title.showBackButton(true);
        StatusBarUtil.setStatusBarLightMode(getWindow());
        img_alipay.setImageResource(R.mipmap.select);
        initListener();



    }

    @Override
    protected void initListener() {
        img_alipay.setOnClickListener(this);
        img_cardpay.setOnClickListener(this);
        wxpay.setOnClickListener(this);
        commit_pay.setOnClickListener(this);
        layout_ali.setOnClickListener(this);
        layout_card.setOnClickListener(this);
        layout_wx.setOnClickListener(this);
    }

    private void select_payType(int type){
        switch (type){
            case 1://支付宝
                img_alipay.setImageResource(R.mipmap.select);
                wxpay.setImageResource(R.mipmap.unselected);
                img_cardpay.setImageResource(R.mipmap.unselected);
                break;
            case 2://微信
                img_alipay.setImageResource(R.mipmap.unselected);
                wxpay.setImageResource(R.mipmap.select);
                img_cardpay.setImageResource(R.mipmap.unselected);
                break;

            case 3://银行卡
                img_alipay.setImageResource(R.mipmap.unselected);
                wxpay.setImageResource(R.mipmap.unselected);
                img_cardpay.setImageResource(R.mipmap.select);
                break;
        }

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.img_alipay:
            case R.id.layout_ali:
                select_payType(1);
                break;
            case R.id.img_wxpay:
            case R.id.layout_wx:
                select_payType(2);
                break;
            case R.id.img_cardpay:
            case R.id.layout_card:
                select_payType(3);
                break;

        }
    }
}
